#pragma once
#include "DeviceUserBase.h"
#include "Resource.h"
#include "Common.h"
#include <string>
#include <vector>


namespace Display
{
	class Mesh;
	class Texture;
	class ResourcePtr;

	class Mesh_ID_Pair
	{
	public:
		Mesh * mesh;
		std::string id;
	};

	class Texture_ID_Pair
	{
	public:
		Texture * texture;
		std::string id;
	};

	class EXPORT ResourcePool : public DeviceUserBase
	{
		std::vector<Mesh_ID_Pair*> meshes;
		std::vector<Mesh_ID_Pair*>::iterator itMeshes;

		std::vector<Texture_ID_Pair*> textures;
		std::vector<Texture_ID_Pair*>::iterator itTextures;

		ResourcePool(void);
		~ResourcePool(void);


	public:
		static ResourcePool * Create(ID3D11Device * device);
		static void Destroy(ResourcePool * pool);

		void DeAllocateMesh(Mesh * resource);
		void DeAllocateTexture(Texture * resource);
	
		bool MeshExist(std::string id);
		bool TextureExist(std::string id);

		
		ResourcePtr * AllocateMesh(std::string id);
		ResourcePtr * AllocateTexture(std::string id);

	private:
		void FreePool();
		void ReleaseAllMeshes();
		void ReleaseAllTextures();

	};

}